package com.apes.enquiry.product.repository;

import com.apes.enquiry.product.model.TyreProduct;
import com.apes.framework.jpa.repository.CustomRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * 类描述：
 *
 * @ClassName TyreExtendRepository
 * @Description 描述
 * @Author lilong
 * @Date 2022/10/31 14:04
 * @Version 1.0
 */
public interface TyreProductRepository extends CustomRepository<TyreProduct,String> {

    @Query(value = "SELECT * FROM  sp_mas_tyre_product T  where T.sp_id=:id",nativeQuery = true)
    TyreProduct findBySpId(@Param("id") String id);

    @Query(value = "select distinct a.figure from TyreProduct a where a.figure like %:key%")
    List findByFigure(String key);

    @Query(value = "select a from TyreProduct a where a.spProduct.spBrand.name = :brandName and a.figure = :figure and a.loadIndex = :loadIndex " +
            "and a.speedClass = :speedClass and a.antiExplosion = :antiExplosion and a.specification = :specification and a.spProduct.supplier.id = :supplier")
    TyreProduct findByAllConditionSupplier(String brandName, String figure, String loadIndex, String speedClass, Boolean antiExplosion, String specification, String supplier);

}
